package com.spring.demo.core.aop;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Aspect
@Component("serviceLogAspect")
public class ServiceLogAspect {

	private Logger logger = LoggerFactory.getLogger(getClass());

	@Pointcut("execution(* com.spring.demo.core.service.*..*Service*.*(..))")
	public void serviceMethod() {
	}

	@Before("serviceMethod() && target(service)")
	public void beforeAdvice(Object service) throws Throwable {
		logger.debug("Accessing {}", service.getClass().getSimpleName());
	}
}
